<?php
namespace app\api\service;
use Qiniu\Auth;
use think\Controller;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/5/26 0026
 * Time: 15:40
 */

class Qiniu extends Controller {

    public static function get_up_token() {
        try {
            $qiniu_config = config('qiniu');
            $bucket = $qiniu_config['bucket'];
            $accessKey = $qiniu_config['ak'];
            $secretKey = $qiniu_config['sk'];
            $auth = new Auth($accessKey, $secretKey);
            $upToken = $auth->uploadToken($bucket);
            return api_return(200, ['token' => $upToken]);

        } catch (\Exception $e) {
            return api_return(0, '', $e->getMessage());
        }
    }
}